﻿using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;

namespace Yoozoo.Gameplay.Liberty.AI.Node
{
    [Category("Ggame/Liberty")]
    public class NpcSearchTarget : AIConditionBaseNode
    {
        // 寻敌间隔
        public BBParameter<float> interval = 0.1f;
        // 是否直接锁定玩家
        public BBParameter<bool> autoLockPlayer = true;
        // 存储目标类型
        public BBParameter<TargetType> storeTargetType = TargetType.PossibleTarget;

        private float _timestamp = 0;
        
        protected override bool OnCheck()
        {
            float t = Time.time;
            if(t >= _timestamp + interval.value)
            {
                _entity.battleAgent.NpcSearchLockTarget(autoLockPlayer.value, storeTargetType.value);
                _timestamp = t;
            }

            return _entity.battleAgent.GetTarget(storeTargetType.value) != null;
        }
    }
}